<template>
  <div class="toys-list-container">
    <el-card class="toys-list-card">
      <template #header>
        <div class="card-header">
          <span>布布的玩具清单</span>
          <el-button type="primary" @click="addToy">添加玩具</el-button>
        </div>
      </template>
      <el-table :data="toysList" style="width: 100%">
        <el-table-column prop="name" label="玩具名称" />
        <el-table-column prop="type" label="类型" />
        <el-table-column prop="buyDate" label="购买日期" />
        <el-table-column prop="status" label="状态">
          <template #default="scope">
            <el-tag :type="scope.row.status === '最爱' ? 'danger' : 'info'">
              {{ scope.row.status }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200">
          <template #default="scope">
            <el-button size="small" @click="editToy(scope.row)">编辑</el-button>
            <el-button size="small" type="danger" @click="deleteToy(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const toysList = ref([
  {
    name: '小熊玩偶',
    type: '毛绒玩具',
    buyDate: '2023-01-01',
    status: '最爱'
  },
  {
    name: '积木套装',
    type: '益智玩具',
    buyDate: '2023-02-15',
    status: '常用'
  },
  {
    name: '小汽车',
    type: '玩具车',
    buyDate: '2023-03-20',
    status: '偶尔玩'
  }
])

const addToy = () => {
  // 添加玩具的逻辑
}

const editToy = (row) => {
  // 编辑玩具的逻辑
}

const deleteToy = (row) => {
  // 删除玩具的逻辑
}
</script>

<style scoped>
.toys-list-container {
  padding: 20px;
}

.toys-list-card {
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style> 